package com.benyanyi.pickerutils;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.benyanyi.picker.PickerHelper;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    List<TestBean> oList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        List<TestBean.Test2Bean> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(new TestBean.Test2Bean(i + ""));
        }
        oList.add(new TestBean("测试1", list));
        oList.add(new TestBean("测试2", list));
        oList.add(new TestBean("测试3", list));
        oList.add(new TestBean("测试4", list));
        oList.add(new TestBean("测试5", list));
        findViewById(R.id.but).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PickerHelper.getInstance().init(MainActivity.this)
                        .setTitle("测试选择")
                        .setData(oList)
                        .setPickerCallback(new PickerHelper.PickerCallback() {
                            @Override
                            public void callback(List<String> msgList, List<Integer> indexList) {
                                Log.v("测试鸭", msgList.toString());
                            }
                        }).show();
            }
        });
        findViewById(R.id.but2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PickerHelper.getInstance().init(MainActivity.this)
                        .setTitle("测试选择2")
                        .setData(oList)
                        .setPickerCallback(new PickerHelper.PickerCallback() {
                            @Override
                            public void callback(List<String> msgList, List<Integer> indexList) {
                                Log.v("测试2鸭", msgList.toString());
                            }
                        }).show();
            }
        });
    }
}